package com.woniuxy.entity.DTO;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;

/**
 * @Author hq
 * @Date 2025/7/13$ 16:20$
 * @Description TODO
 * @Params $
 * @Return $
 **/
public class PageResponseDTO<T> {

    private int pageNum;      // 当前页码
    private int pageSize;     // 每页数量
    private long total;       // 总记录数
    private List<T> list;     // 当前页数据列表

    public static <T> PageResponseDTO<T> build(Page<T> page) {
        PageResponseDTO<T> response = new PageResponseDTO<>();
        response.setPageNum((int) page.getCurrent());
        response.setPageSize((int) page.getSize());
        response.setTotal(page.getTotal());
        response.setList(page.getRecords());
        return response;
    }

    // Getter 和 Setter 方法
    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
